Skip to main content

Integrals and Probability Density Functions

Area Under a Curve

The area under a curve between x=ax=a and x=bx=b (for a positive function) is called the integral of the function.

Fig. 28

Figure: Example 1, 2 and 3

Details

Definition

The area under a curve between x=ax=a and x=bx=b (for a positive function) is called the integral of the function and is denoted: abf(x)dx\int_{a}^{b} f(x)dx when it exists.

The Antiderivative

Given a function ff, if there is another function FF such that F=fF'=f, we say that FF is the antiderivative of ff. For a function ff the antiderivative is denoted by fdx\int f dx.

Note that if FF is one antiderivative of ff and CC is a constant, then G=F+CG=F+C is also an antiderivative. It is therefore customary to always include the constant, e.g. xdx=12x2+C\int x dx=\displaystyle\frac{1}{2}x^2+C.

Examples

Example

The antiderivative of xx to a power raises the power by one and divides it by the new power:

xndx=1n+1xn+1+C\int x^n dx=\displaystyle\frac{1}{n+1}x^{n+1} +C

Example

exdx=ex+C\int e^x dx=e^x+C

Example

1xdx=ln(x)+C\int \displaystyle\frac{1}{x} dx=\ln(x)+C

Example

2xex2dx=ex2+C\int 2xe^{x^2} dx=e^{x^2}+C

The Fundamental Theorem of Calculus

If ff is a continuous function, and F(x)=f(x)F'(x)=f(x) for x[a,b]x\in[a,b], then abf(x)dx=F(b)F(a)\int_a^b f(x)dx=F(b)-F(a)

Detail

It is not too hard to see that the area under the graph of a positive function ff on the interval [a,b][a,b] must be equal to the difference of the values of its antiderivative at aa and bb. This also holds for functions which take on negative values and is formally stated below.

Definition

Fundamental theorem of calculus: If FF is the antiderivative of the continuous function ff, i.e. F=fF'=f for x[a,b]x\in[a,b], then abf(x)dx=F(b)F(a)\int_a^b f(x)dx=F(b)-F(a).

This difference is often written as abfdx\int_a^b f dx or [F(x)]ab[F(x)]_a ^b.

Examples

Example

The area under the graph of xnx^n between 00 and 33 is 03xndx=[1n+1xn+1]03=1n+13n+11n+10n+1=3n+1n+1\int_0^3 x^n dx = [\displaystyle\frac{1}{n+1}x^{n+1}]_0 ^3=\displaystyle\frac{1}{n+1}3^{n+1}-\displaystyle\frac{1}{n+1}0^{n+1}=\displaystyle\frac{3^{n+1}}{n+1}

Example

The area under the graph of exe^x between 33 and 44 is 34exdx=[ex]34=e4e3\int_3^4 e^x dx =[e^x]_3 ^4= e^4-e^3

Example

The area under the graph of 1x\displaystyle\frac{1}{x} between 11 and aa is 1a1xdx=[ln(x)]1a=ln(a)ln(1)=ln(a)\int_1^a \displaystyle\frac{1}{x} dx =[\ln(x)]_1 ^a= \ln(a)-\ln(1)=\ln(a)

Density Functions

The probability density function (p.d.f.) and the cumulative distribution function (c.d.f.).

Fig. 29

Details

Definition

If XX is a random variable such that

P(aXb)=abf(x)dxP(a\leq X\leq b)=\int\limits^{b}_{a}f(x)dx

for some function ff which satisfies f(x)0f(x)\geq0 for all xx and

f(x)dx=1\int\limits^\infty_{-\infty} f(x)dx = 1

then ff is said to be a probability density function (p.d.f.) for XX.

Definition

The function

F(x)=xf(t)dtF(x)= \int\limits^{x}_{-\infty} f(t)dt

is the cumulative distribution function (c.d.f.).

Examples

Example

Consider a random variable XX from the uniform distribution, denoted by XUnf(0,1)X\sim Unf(0,1). This distribution has density:

f(x)={1if 0x10e.w.f(x) = \begin{cases} 1 &\text{if } 0 \leq x \leq 1 \\ 0 &\text{e.w.} \end{cases}

The cumulative distribution function is given by:

P[Xx]=xf(t)dt={0if x<0xif 0x11elseP[X\leq x] = \int\limits^{x}_{-\infty} f(t)dt = \begin{cases} 0 & \text{if } x < 0 \\ x & \text{if } 0 \leq x \leq 1 \\ 1 & \text{else} \end{cases}
Example

Suppose XP(λ)X \sim P(\lambda), where XX may denote the number of events per unit time. The p.m.f. of XX is described by

p(x)=P[X=x]=eλλxx! for x=0,1,2,p(x)=P[X=x]=e^{-\lambda}\displaystyle\frac{\lambda^x}{x!} \text{ for } x = 0,1,2,\dots

Let TT denote the waiting time between events, or simply until the first event. Consider the event T>tT>t for some number t>0t>0. If Xp(λ)X\sim p(\lambda) denotes the number of events per unit time, then let XtX_t be the number of events during the time period for 00 through tt. Then it is natural to assume XtP(λt)X_t \sim P(\lambda t) and it follows that T>tT>t if and only if Xt=0X_t=0 and we obtain P[T>t]=P[Xt=0]=eλtP[T>t]=P[X_t=0]=e^{-\lambda t}. It follows that the c.d.f. of TT is

FT(t)=P[Tt]=1P[T>t]=1eλt for t>0F_T(t)=P[T\leq t]=1-P[T>t]=1-e^{-\lambda t} \text{ for } t > 0

The p.d.f. of TT is therefore

fT(t)=FT(t)=ddtFT(t)=ddt(1eλt)=0eλt(λ)=λeλtf_T(t)=F_T'(t)=\displaystyle\frac{d}{dt}F_T(t)=\displaystyle\frac{d}{dt}(1-e^{-\lambda t})=0-e^{- \lambda t} \cdot (-\lambda)=\lambda e^{-\lambda t}

for t0t \geq 0 and fT(t)=0 for t<0f_T(t)=0 \text{ for } t < 0

The resulting density

f(t)={λeλtfor t00for t<0f(t) = \begin{cases} \lambda e^{-\lambda t} & \text{for } t \geq0 \\ 0 & \text{for } t<0 \end{cases}

describes the exponential distribution.

This distribution has the expected value

E[T]=tf(t)dt=λ0teλtdtE[T]=\int_{-\infty}^{\infty} tf(t)dt=\lambda \int_{0}^{\infty} t e^{-\lambda t}dt

Let's use integration by parts (see below), i.e.: fg=fgfg\int fg' = fg - \int f'g to solve that integral. Let f=tf=t and g=eλtg'=e^{-\lambda t}. Then f=1f' = 1 and g=eλtλg=-\displaystyle\frac{e^{- \lambda t}}{\lambda}. We obtain:

=λ([teλtλ]00eλtλdt)=λ((00)[eλtλ2]0)=λ(01λ2)=1λ\begin{aligned} &= \lambda \left( \left[ \displaystyle\frac{-te^{-\lambda t}}{\lambda}\right]_{0}^{\infty} - \int_0^\infty - \displaystyle\frac{-e^{-\lambda t}}{\lambda} dt \right) \\ &= \lambda \left( (0 - 0) - \left[ \displaystyle\frac{e^{-\lambda t}}{\lambda^2} \right]_0^\infty \right) \\ &= -\lambda \left(0 - \displaystyle\frac{1}{\lambda^2}\right) \\ &= \displaystyle\frac{1}{\lambda} \end{aligned}

Probabilities In R: The Normal Distribution

R has functions to compute values of probability density functions (p.d.f.) and cumulative distribution functions (c.m.d.) for most common distributions.

Details

The p.d.f. for the normal distribution is

p(t)=12πet22p(t)=\displaystyle\frac{1}{\sqrt{2\pi}}e^{-\displaystyle\frac{t^2}{2}}

The c.d.f. for the normal distribution is

Φ(x)=x12πet22dt\Phi(x)=\int_{-\infty}^x\displaystyle\frac{1}{\sqrt{2\pi}}e^{-\displaystyle\frac{t^2}{2}}dt

Examples

Example

dnorm() gives the value of the normal p.d.f.

Example

pnorm() gives the value of the normal c.d.f.

Some Rules of Integration

Examples

Example

Using integration by parts we obtain:

ln(x)xdx=12x2ln(x)12x21xdx=12x2ln(x)12xdx=12x2ln(x)14x2\int \ln(x)x dx= \displaystyle\frac{1}{2}x^2\ln(x)-\int \displaystyle\frac{1}{2}x^2\cdot \displaystyle\frac{1}{x} dx = \displaystyle\frac{1}{2}x^2\ln(x)-\int \displaystyle\frac{1}{2}x dx=\displaystyle\frac{1}{2}x^2\ln(x)-\displaystyle\frac{1}{4}x^2

Example

Consider 122xex2dx\int_1^2 2xe^{x^2} dx. By setting x=g(t)=tx=g(t)=\sqrt{t} we obtain

122xex2dx=142tet12tdt=14etdt=e4e\int_1^2 2xe^{x^2} dx = \int_1^4 2\sqrt{t}e^{t}\displaystyle\frac{1}{2\sqrt{t}}dt=\int_1^4 e^t dt=e^4-e

Handout

The two most common "tricks" applied in integration are a) integration by parts and b) integration by substitution

a) Integration by parts

(fg)=fg+fg(fg)'=f'g+fg'

by integrating both sides of the equation we obtain:

fg=fgdx+fgdxfgdx=fgfgdxfg=\int f'g dx + \int fg' dx \leftrightarrow \int fg' dx=fg-\int f'g dx

b) Integration by substitution

Consider the definite integral abf(x)dx\int_a^b f(x) dx and let gg be a one-to-one differential function for the interval (c,d)(c,d) to (a,b)(a,b). Then

abf(x)dx=cdf(g(y))g(y)dy\int_a^b f(x) dx=\int_c^d f(g(y))g'(y) dy